/**
 *
 */
package de.cbf.cam.dsa.rcp.model.entities;

import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;

import de.cbf.cam.dice.entities.RollDefinitionSum;
import de.cbf.util.uuidheader.entities.EntityWeighted;
import de.cbf.util.uuidheader.entities.UUIDHeader;
import de.cbf.util.uuidheader.exceptions.EntityMergeException;

/**
 * @author Surfer
 *
 */
@XmlRootElement(name = "race")
public class RaceDSA extends RCPPerked implements Cloneable {
	@XmlElementWrapper(name="eye_colors")
	@XmlElement(name="eye_color")
	protected List<EntityWeighted> 	possibleEyeColors 	= new ArrayList<EntityWeighted>();
	@XmlElementWrapper(name="hair_colors")
	@XmlElement(name="hair_color")
	protected List<EntityWeighted> 	possibleHairColors	= new ArrayList<EntityWeighted>();
	protected RollDefinitionSum 	heigthRollDefinition;


	@Override
	public Object clone() throws CloneNotSupportedException {
		RaceDSA clone = new RaceDSA();
		clone.fName = fName;
		clone.possibleEyeColors.addAll(possibleEyeColors);
		clone.possibleHairColors.addAll(possibleHairColors);
		return clone;
	}

	@Override
	protected void doMergeDataFrom(UUIDHeader entity, boolean i_am_older)
			throws EntityMergeException {
		super.doMergeDataFrom(entity, i_am_older);
		if (entity instanceof RaceDSA) {
			RaceDSA other = (RaceDSA) entity;
			if(i_am_older){
				this.heigthRollDefinition = other.heigthRollDefinition;
				possibleEyeColors.clear();
				possibleEyeColors.addAll(other.possibleEyeColors);
				possibleHairColors.clear();
				possibleHairColors.addAll(other.possibleHairColors);
			}
		}else{
			throw new EntityMergeException("Entity does not fit class:"+this.getClass().getName());
		}

	}


	public List<EntityWeighted> getPossibleEyeColors() {
		return possibleEyeColors;
	}


	public void setPossibleEyeColors(List<EntityWeighted> possibleEyeColors) {
		this.possibleEyeColors = possibleEyeColors;
	}


	public List<EntityWeighted> getPossibleHairColors() {
		return possibleHairColors;
	}


	public void setPossibleHairColors(List<EntityWeighted> possibleHairColors) {
		this.possibleHairColors = possibleHairColors;
	}
	public RollDefinitionSum getHeigthRollDefinition() {
		return heigthRollDefinition;
	}



	public void setHeigthRollDefinition(RollDefinitionSum heigthRollDefinition) {
		this.heigthRollDefinition = heigthRollDefinition;
	}




}
